﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace qFS_Windows
{
    class Program
    {
        static void Main(string[] args)
        {
            incBuildNumber();
            Console.WriteLine("qFS For Windows");
            System.IO.StreamReader ver = new System.IO.StreamReader("version");
            Console.WriteLine(ver.ReadLine() + " Release " + ver.ReadLine() + " Build " + ver.ReadLine());
            ver.Close();
            Console.WriteLine("---");
        aircraft:
            Console.Write("Please enter aricraft name:");
            string plane_file = Console.ReadLine();
            System.IO.StreamReader aircraft;
            try
            {
                aircraft = new System.IO.StreamReader("aircraft/" + plane_file + ".acp");
            }
            catch
            {
                Console.WriteLine("Could not open the file.\nPlease ensure that the file exists and is called:" + plane_file);
                goto aircraft;
            }
            string inp = "";
            int propid = 0;
            string propval = "";
            while (!aircraft.EndOfStream)
            {
                inp = aircraft.ReadLine();
                propid = int.Parse(inp.Substring(0, 3));
                propval = inp.Substring(4,(inp.Length-4));
                Console.WriteLine("Property: " + propid + " has value: " + propval);
            }
            Console.ReadLine();
        }
        public static void incBuildNumber()
        {
            System.IO.StreamReader verrread = new System.IO.StreamReader("version");
            string n = verrread.ReadLine();
            string r = verrread.ReadLine();
            string b = verrread.ReadLine();
            verrread.Close();
            b = (int.Parse(b) + 1).ToString();
            System.IO.StreamWriter verwrite = new System.IO.StreamWriter("version");
            verwrite.WriteLine(n);
            verwrite.WriteLine(r);
            verwrite.WriteLine(b);
            verwrite.Close();
        }
    }
}